//
//  Ext+UIImageView.swift
//  langligelang
//
//  Created by 秦－政 on 2016/10/23.
//  Copyright © 2016年 pete. All rights reserved.
//

import UIKit
import SDWebImage
extension UIImageView{
    
    /// 快速创建 imageView
    ///
    /// - parameter imgName:  图片名字
    ///
    /// - returns:
    convenience init(imgName: String){
        
        self.init(image: UIImage(named: imgName))
    }
    
    /// 对SDWebImage 进行封装
    ///
    /// - parameter withUrlString:      图片的 urlString
    /// - parameter placeholderImgName:  默认图片的名字
    func sl_setImage(withUrlString: String?, placeholderImgName: String?){
        // URL
        let url = URL(string: withUrlString ?? "")
        // 判断他是否为 nil
        guard let u = url else {
            return
        }
        // 调用 sdWebImage
        self.sd_setImage(with: u, placeholderImage: UIImage(named: placeholderImgName ?? ""))
    }
}
